<?php defined('IN_YuLin') || exit('NO PERMIT!'); ?>
{template index/header}

<style>
.table-list thead th{ height:30px; background:#eef3f7; border-bottom:1px solid #d5dfe8; font-weight:normal}
.table-list tbody td,.table-list .btn{border-bottom: #eee 1px solid; padding-top:8px; padding-bottom:8px}
.table-list tbody td.text-c{ padding-left:0;}
</style>

<link href="static/css/jquery.treeTable.css" rel="stylesheet" type="text/css" />
<script src="static/js/jquery.treetable.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $("#dnd-example").treeTable({
            indent: 20
        });
    });
    function checknode(obj)
    {
        var level = $(obj).attr('data-level');
        var pid = $(obj).attr('data-pid');
        var checked = $(obj).prop('checked');
        
        //  所有上级跟着选中
        if(checked && level > 0)
        {
            //  上级
            while($('#node-' + pid).length > 0)
            {
                $('#node-' + pid).find('input[type="checkbox"]').prop('checked',true);
                pid = $('#node-' + pid).attr('data-pid');
                
                console.log(pid);
            }
        }
        
        //  下级、最多三级
        var son = $(obj).val();
        if($('.child-of-node-' + son).length > 0)
        {
            $('.child-of-node-' + son).each(function(){
                $(this).find('input[type="checkbox"]').prop('checked',checked);
                
                //  下级
                if($('.child-of-node-' + $(this).find('input[type="checkbox"]').val()).length > 0)
                {
                    $('.child-of-node-' + $(this).find('input[type="checkbox"]').val()).find('input[type="checkbox"]').prop('checked',checked);
                }
            });
        }
    }
    function quanxuan(flag)
    {
        $('input[name="menuid[]"]').prop('checked', flag ? true : false);
    }
</script>

<div class="table-list" id="load_priv">
    <table width="100%" cellspacing="0">
    	<thead>
        	<tr>
        	   <th class="text-l cu-span" style='padding-left:30px;'><span onclick="quanxuan(1)">全选</span>/<span onclick="quanxuan(0)">取消</span></th>
        	</tr>
    	</thead>
    </table>
    <form name="myform" action="?" method="post">
        <input type="hidden" name="m" value="{$m}" />
        <input type="hidden" name="c" value="{$c}" />
        <input type="hidden" name="a" value="{$a}" />
        <input type="hidden" name="id" value="{$id}" />
        <table width="100%" cellspacing="0" id="dnd-example">
            <tbody>{$menu}</tbody>
        </table>
        <div class="btn submit-btn" style="padding-left:20px;"><input type="submit" id="dosubmit" class="layui-btn" name="dosubmit" value="提交"/></div>
    </form>
</div>

{template index/footer}